package com.ruoyi.mall.controller;

import java.util.List;

import com.ruoyi.mall.domain.MallMemberUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallShopExpressCode;
import com.ruoyi.mall.service.IMallShopExpressCodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 快递编码Controller
 *
 * @author chang
 * @date 2021-11-25
 */
@RestController
@RequestMapping("/mall/mallShopExpressCode")
public class MallShopExpressCodeController extends BaseController
{
    @Autowired
    private IMallShopExpressCodeService mallShopExpressCodeService;

    /**
     * 查询快递编码列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallShopExpressCode:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallShopExpressCode mallShopExpressCode)
    {
        startPage();
        List<MallShopExpressCode> list = mallShopExpressCodeService.selectMallShopExpressCodeList(mallShopExpressCode);
        return getDataTable(list);
    }

    /**
     * 导出快递编码列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallShopExpressCode:export')")
    @Log(title = "快递编码", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallShopExpressCode mallShopExpressCode)
    {
        List<MallShopExpressCode> list = mallShopExpressCodeService.selectMallShopExpressCodeList(mallShopExpressCode);
        ExcelUtil<MallShopExpressCode> util = new ExcelUtil<MallShopExpressCode>(MallShopExpressCode.class);
        return util.exportExcel(list, "快递编码数据");
    }

    /**
     * 获取快递编码详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallShopExpressCode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallShopExpressCodeService.selectMallShopExpressCodeById(id));
    }

    /**
     * 新增快递编码
     */
    @PreAuthorize("@ss.hasPermi('mall:mallShopExpressCode:add')")
    @Log(title = "快递编码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallShopExpressCode mallShopExpressCode)
    {
        return toAjax(mallShopExpressCodeService.insertMallShopExpressCode(mallShopExpressCode));
    }

    /**
     * 修改快递编码
     */
    @PreAuthorize("@ss.hasPermi('mall:mallShopExpressCode:edit')")
    @Log(title = "快递编码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallShopExpressCode mallShopExpressCode)
    {
        return toAjax(mallShopExpressCodeService.updateMallShopExpressCode(mallShopExpressCode));
    }

    /**
     * 删除快递编码
     */
    @PreAuthorize("@ss.hasPermi('mall:mallShopExpressCode:remove')")
    @Log(title = "快递编码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallShopExpressCodeService.deleteMallShopExpressCodeByIds(ids));
    }

    /**
     * 查询快递列表
     */
    @GetMapping("/getExpressList")
    public AjaxResult getUserList(MallShopExpressCode mallShopExpressCode)
    {
        List<MallShopExpressCode> list = mallShopExpressCodeService.selectMallShopExpressCodeList(mallShopExpressCode);
        return AjaxResult.success(list);
    }
}
